package org.budo.support.spring.boot.web.registration;

import javax.servlet.Filter;

import org.budo.support.lang.util.ListUtil;
import org.springframework.boot.web.servlet.FilterRegistrationBean;

/**
 * @author lmw
 */
public class RegistrationUtil {
    public static FilterRegistrationBean filter(Filter filter, String urlPattern) {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(filter);
        filterRegistrationBean.setUrlPatterns(ListUtil.toList(urlPattern));
        return filterRegistrationBean;
    }

    public static FilterRegistrationBean filter(Filter filter, String urlPattern, Integer order) {
        FilterRegistrationBean filterRegistrationBean = filter(filter, urlPattern);
        filterRegistrationBean.setOrder(order);
        return filterRegistrationBean;
    }
}